import axios from 'axios';

var plantService = {};
// process.env.API_HOST
// poetryService.poetry = function() {
//     return axios.post(process.env.API_HOST + "admin/poetry")
//     .then((res)=> {
//         return res;
//     })
//     .catch((error)=> {
//         throw error;
//     })
// }
// 查询poetry信息
plantService.search = function (index, pagesize) {
    let data = {
        pageIndex: index,
        pageSize: pagesize,
    }
    return axios.post(process.env.API_HOST + "admin/poetry/search", data)
        .then(function (res) {
            return res;
        })
        .catch(function (error) {
            throw error;
        })
};
// 添加一条信息
plantService.add = function (tit, main) {
    let data = {
        poetryTit: tit,
        poetryMain: main,
    }
    return axios.post(process.env.API_HOST + "admin/poetry/add", data)
        .then(function (res) {
            return res;
        })
        .catch(function (error) {
            throw error;
        })
};
// 删除一条信息
plantService.deleteOnce = function (id) {
    let data = {
        id: id,
    }
    return axios.post(process.env.API_HOST + "admin/poetry/deleteOnce", data)
        .then(function (res) {
            return res;
        })
        .catch(function (error) {
            throw error;
        })
};
// 删除多条信息
plantService.deleteMany = function (id) {
    let data = {
        id: id,
    }
    return axios.post(process.env.API_HOST + "admin/poetry/deleteMany", data)
        .then(function (res) {
            return res;
        })
        .catch(function (error) {
            throw error;
        })
};
// 更新一条信息
plantService.updateOnce = function (id, tit, main) {
    let data = {
        id: id,
        poetryTit: tit,
        poetryMain: main,
    }
    return axios.post(process.env.API_HOST + "admin/poetry/updateOnce", data)
        .then(function (res) {
            return res;
        })
        .catch(function (error) {
            throw error;
        })
};
export { plantService };
